/**
 * Created by Administrator on 2015/1/12.
 */
app.factory("userService",["basicHttp",function(basicHttp){
    var promise;
    var service = {
        //用户登录
        login: function(options){
            //api/v1/LearnDriving/Apply
            promise = basicHttp.http({
                //http请求的类型
                method: 'POST',
                //表示请求的绝对或者相对资源路径
                url: basicHttp.prefixUrl + "user/login",
                //一个字符串或者一个对象
                data: options
            }).then(function(response){
                return response.data;
            });
            return promise;
        },
        //用户登出
        logout: function(options){
            basicHttp.setAuthToken();
            promise = basicHttp.http({
                method:'GET',
                url: basicHttp.prefixUrl + "user/logout",
                params: options
            }).then(function(response){
                return response.data;
            });
            return promise;
        },
        adsImg:function(options){
            basicHttp.setAuthToken();
            promise = basicHttp.http({
                method: 'GET',
                url : basicHttp.prefixUrl + 'Ads/Get',
                params: options
            }).then(function (response) {
                return response.data;
            })
            return promise;
        },
        postFeedback: function (options) {
            basicHttp.setAuthToken();
            promise = basicHttp.http({
                method : 'POST',
                url : basicHttp.prefixUrl + 'Feedback/Post',
                data : options
            }).then(function (response) {
                return response.data;
            });
              return promise;
        },
        aboutUs : function () {
            basicHttp.setAuthToken();
            promise = basicHttp.http({
                method:'GET',
                url: basicHttp.prefixUrl + 'AboutUs/Get'
            }).then(function (response) {
                return response.data;
            });
            return promise;
        },
        //找回密码
        findPassWord: function(options){
            basicHttp.setAuthToken();
            promise = basicHttp.http({
                method: 'POST',
                url: basicHttp.prefixUrl + "User/ForgetPassword",
                data: options
            }).then(function(response){
              //  alert(JSON.stringify(response.data));
                return response.data;
            });
            return promise;
        },
        //登录完成获取个人信息
        getUserInfo:function(){
            basicHttp.setAuthToken();
            promise = basicHttp.http({
                method: 'Get',
                url: basicHttp.prefixUrl + "Consultant/GetProfile"
            }).then(function(response){
                return response.data;
            });
            return promise;
        },

        getConsultantProfile: function(){
            basicHttp.setAuthToken();
            promise = basicHttp.http({
                method: "GET",
                url: basicHttp.prefixUrl + "Consultant/GetProfile"
            }).then(function(response){
                return response.data;
            })
            return promise;
        },

        updateConsultantProfile: function(options){
            basicHttp.setAuthToken();
            promise = basicHttp.http({
                method: "POST",
                url : basicHttp.prefixUrl + "Consultant/UpdateProfile",
                data: options
            }).then(function(response){
                return response.data;
            })
            return promise;
        },
        //检测无效token并进行处理
        isValidatedAutoTken: function(options){
            basicHttp.setAuthToken();
            promise = basicHttp.http({
                method: 'GET',
                url: basicHttp.prefixUrl + 'user/Validate',
                params: options
            }).then(function (response) {
                return response.data;
            });
            return promise;
        },
        getMyTopics: function(options){
            basicHttp.setAuthToken();
            promise = basicHttp.http({
                method: 'GET',
                url: basicHttp.prefixUrl + "SNS/GetMyTopics",
                params: options
            }).then(function(response){
                return response.data;
            });
            return promise;
        },
        //获取验证码
        getShortMsg: function(options){
            basicHttp.setAuthToken();
            promise = basicHttp.http({
                method: 'Get',
                url:  basicHttp.prefixUrl + "user/shortMsg",
                params: options
            }).then(function(response){
                return response.data;
            });
            return promise;
        },
        //用户注册
        userRegister: function(options){
            basicHttp.setAuthToken();
            promise = basicHttp.http({
                method: 'POST',
                url: basicHttp.prefixUrl + "user/register",
                data: options
            }).then(function(response){
                return response.data;
            });
            return promise;
        },
        //用户更新详细信息
        updateInfo: function(options){
            basicHttp.setAuthToken();
            promise = basicHttp.http({
                method: 'POST',
                url: basicHttp.prefixUrl + "user/updateInfo",
                data: options
            }).then(function(response){
                return response.data;
            });
            return promise;
        },
        //获取用户详细信息
        getProfile: function(options){
            basicHttp.setAuthToken();
            promise = basicHttp.http({
                method: "GET",
                url: basicHttp.prefixUrl + "user/getProfile",
                params: options
            }).then(function(response){
                return response.data;
            });
            return promise;
        },
        //获取指定用户详细信息
        getProfileById: function(options){
            basicHttp.setAuthToken();
            promise = basicHttp.http({
                method: "GET",
                url: basicHttp.prefixUrl + "user/getProfileById",
                params: options
            }).then(function(response){
                return response.data;
            });
            return promise;
        },
        //申请加好友
        applyFriend: function(options){
            basicHttp.setAuthToken();
            promise = basicHttp.http({
                method: "GET",
                url: basicHttp.prefixUrl + "friend/applyFriend",
                params: options
            }).then(function(response){
                return response.data;
            });
            return promise;
        },
        //接受好友请求
        processFriendRequest : function(options){
            basicHttp.setAuthToken();
            promise = basicHttp.http({
                method: "GET",
                url: basicHttp.prefixUrl + "friend/processFriendRequest",
                params: options
            }).then(function(response){
                return response.data;
            });
            return promise;
        },
        //获取好友列表
        getFriends : function(){
            basicHttp.setAuthToken();
            promise = basicHttp.http({
                method: "GET",
                url: basicHttp.prefixUrl + "friend/getFriends"
            }).then(function(response){
                return response.data;
            });
            return promise;
        },
        //获取好友请求
        getFriendRequest: function(options){
            basicHttp.setAuthToken();
            promise = basicHttp.http({
                method: "GET",
                url: basicHttp.prefixUrl + "friend/getFriendRequest",
                params: options
            }).then(function(response){
                return response.data;
            });
            return promise;
        },
        //搜索好友
        searchFriends: function(options){
            basicHttp.setAuthToken();
            promise = basicHttp.http({
                method: "Get",
                url: basicHttp.prefixUrl + "user/search",
                params: options
            }).then(function(response){
                return response.data;
            });
            return promise;
        },
        //删除对应相册里面的照片
        deletePhoto : function(options){
            basicHttp.setAuthToken();
            promise = basicHttp.http({
                method: "POST",
                url: basicHttp.prefixUrl + "file/deletePhoto",
                data: options
            }).then(function(response){
                return response.data;
            });
            return promise;
        },
        //获取国家
       getCountry: function(options){
           basicHttp.setAuthToken();
           promise = basicHttp.http({
               method: "GET",
               url: basicHttp.prefixUrl + "area/getCountry",
               params: options
           }).then(function(response){
               return response.data;
           });
           return promise;
       },
        //获取省份
        getProvince: function(options){
            basicHttp.setAuthToken();
            promise = basicHttp.http({
                method: "GET",
                url: basicHttp.prefixUrl + "area/getProvince",
                params: options
            }).then(function(response){
                return response.data;
            });
            return promise;
        },
        //获取市
        getCity: function(options){
            basicHttp.setAuthToken();
            promise = basicHttp.http({
                method: "GET",
                url: basicHttp.prefixUrl + "area/getCity",
                params: options
            }).then(function(response){
                return response.data;
            });
            return promise;
        },
        //购买套餐
        buyPlan: function(options){
            basicHttp.setAuthToken();
            promise = basicHttp.http({
                method: "POST",
                url: basicHttp.prefixUrl + "user/buyPlan",
                data: options
            }).then(function(response){
                return response.data;
            });
            return promise;
        },
        //积分套餐
        getScorePlan: function(options){
            basicHttp.setAuthToken();
            promise = basicHttp.http({
                method: "GET",
                url: basicHttp.prefixUrl + "user/getScorePlan",
                params: options
            }).then(function(response){
                return response.data;
            });
            return promise;
        },
        //vip套餐
        getVipPlan: function(options){
            basicHttp.setAuthToken();
            promise = basicHttp.http({
                method: "GET",
                url: basicHttp.prefixUrl + "user/getVipPlan",
                params: options
            }).then(function(response){
                return response.data;
            });
            return promise;
        },
        //获取每日推荐
        getRecommend: function(options){
            basicHttp.setAuthToken();
            promise = basicHttp.http({
                method: "GET",
                url: basicHttp.prefixUrl + "user/getRecommend",
                params: options
            }).then(function(response){
                return response.data;
            });
            return promise;
        },
        //获取首页推荐
        getRecommendMember: function(options){
            basicHttp.setAuthToken();
            promise = basicHttp.http({
                method: "GET",
                url: basicHttp.prefixUrl + "user/getRecommendMember",
                params: options
            }).then(function(response){
                return response.data;
            });
            return promise;
        },
        //修改交友状态
        updateDatingStatus: function(options){
            basicHttp.setAuthToken();
            promise = basicHttp.http({
                method: "POST",
                url: basicHttp.prefixUrl + "user/updateDatingStatus",
                data: options
            }).then(function(response){
                return response.data;
            });
            return promise;
        },
        //获取总积分
        getScore: function(options){
            basicHttp.setAuthToken();
            promise = basicHttp.http({
                method: "GET",
                url: basicHttp.prefixUrl + "user/getScore",
                params: options
            }).then(function(response){
                return response.data;
            });
            return promise;
        },
        //获取收藏列表
        getCollects: function(options){
            basicHttp.setAuthToken();
            promise = basicHttp.http({
                method: "GET",
                url: basicHttp.prefixUrl + "user/getCollects",
                params: options
            }).then(function(response){
                return response.data;
            });
            return promise;
        },
        //添加收藏
        collect: function(options){
            basicHttp.setAuthToken();
            promise = basicHttp.http({
                method: "POST",
                url: basicHttp.prefixUrl + "user/collect",
                data: options
            }).then(function(response){
                return response.data;
            });
            return promise;
        },
        //删除好友
        removeFriend:function(options){
            basicHttp.setAuthToken();
            promise = basicHttp.http({
                method: "POST",
                url: basicHttp.prefixUrl + 'friend/removeFriend',
                data: options
            }).then(function(response){
                return response.data;
            });
            return promise;
        },
        //获取用户角色
        getRole:function(options){
            basicHttp.setAuthToken();
            promise = basicHttp.http({
                method: 'GET',
                url: basicHttp.prefixUrl + 'user/getRole',
                params: options
            }).then(function(response){
                return response.data;
            });
            return promise;
        },
        //获取是否是好友
        getProcessStatus:function(options){
            basicHttp.setAuthToken();
            promise = basicHttp.http({
                method: 'GET',
                url: basicHttp.prefixUrl + 'friend/getProcessStatus',
                params: options
            }).then(function(response){
                return response.data;
            });
            return promise;
        },
        //修改密码
        changePassword: function(options){
            basicHttp.setAuthToken();
            promise = basicHttp.http({
                method: 'POST',
                url: basicHttp.prefixUrl + 'user/changePassword',
                data: options
            }).then(function(response){
                return response.data;
            });
            return promise;
        },
        //获取最后一次的搜索结果
        getLastSearch: function(options){
            basicHttp.setAuthToken();
            promise = basicHttp.http({
                method: 'GET',
                url: basicHttp.prefixUrl + 'user/getLastSearch',
                params: options
            }).then(function(response){
                return response.data;
            });
                return promise;
        },
        //分享成功后加积分
        shareInfo: function(options){
            basicHttp.setAuthToken();
            promise = basicHttp.http({
                method: 'GET',
                url: basicHttp.prefixUrl + 'user/shareInfo',
                params: options
            }).then(function(response){
                return response.data;
            });
            return promise;
        },
        //获取版本信息
        appVersion: function(options){
            basicHttp.setAuthToken();
            promise = basicHttp.http({
                method: 'GET',
                url: basicHttp.prefixUrl + 'appVersion/get',
                params: options
            }).then(function(response){
                return response.data;
            });
            return promise;
        },
        //获取调用api的url
        deviceEnvironment: function(options){
            basicHttp.setAuthToken();
            promise = basicHttp.http({
                method: 'GET',
                url: basicHttp.prefixUrl + 'deviceEnvironment/get',
                params: options
            }).then(function(response){
                return response.data;
            });
            return promise;
        },
        //取消收藏
        cancelCollect: function(options){
            basicHttp.setAuthToken();
            promise = basicHttp.http({
                method: 'GET',
                url: basicHttp.prefixUrl + 'user/cancelCollect',
                params: options
            }).then(function(response){
                return response.data;
            });
            return promise;
        },
        //获取好友请求未读个书
        getUnReadCount: function(){
            basicHttp.setAuthToken();
            promise = basicHttp.http({
                method: 'GET',
                url: basicHttp.prefixUrl + 'friend/getUnReadCount'
            }).then(function(response){
                return response.data;
            });
            return promise;
        },
        //清除请求未读记录
        clearUnRead: function(options){
            basicHttp.setAuthToken();
            promise = basicHttp.http({
                method: 'POST',
                url: basicHttp.prefixUrl + 'friend/clearUnRead',
                data: options
            }).then(function(response){
                return response.data;
            });
            return promise;
        }
    }
    return service;
}]);